<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>门店区域划分表管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox") || element.is(":radio") || element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ajz/ajzBaseinfo/">门店区域划分表列表</a></li>
		<li class="active"><a href="${ctx}/ajz/ajzBaseinfo/form?id=${ajzBaseinfo.id}&parent.id=${ajzBaseinfoparent.id}">门店区域划分表<shiro:hasPermission name="ajz:ajzBaseinfo:edit">${not empty ajzBaseinfo.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="ajz:ajzBaseinfo:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="ajzBaseinfo" action="${ctx}/ajz/ajzBaseinfo/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>		
		<form:input path="parentId" value="" htmlEscape="false" maxlength="100" class="hide"/>
		<%-- <div class="control-group">
			<label class="control-label">上级id:</label>
			<div class="controls">
				<sys:treeselect id="parent" name="parent.id" value="${ajzBaseinfo.parent.id}" labelName="parent.name" labelValue="${ajzBaseinfo.parent.enterpriseName}"
					title="parent_id" url="/ajz/ajzBaseinfo/treeData" extId="${ajzBaseinfo.id}" cssClass="" allowClear="true"/>
			</div>
		</div> --%>
		<div class="control-group">
			<label class="control-label">单位名称：</label>
			<div class="controls">
				<form:input path="enterpriseName" htmlEscape="false" maxlength="100" class="input-xlarge required"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">负责人姓名：</label>
			<div class="controls">
				<form:input path="chargePerson" htmlEscape="false" maxlength="64" class="input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">经营者姓名：</label>
			<div class="controls">
				<form:input path="managerPerson" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">职务：</label>
			<div class="controls">
				<form:input path="post" htmlEscape="false" maxlength="200" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">手机号：</label>
			<div class="controls">
				<form:input path="telephone" htmlEscape="false" maxlength="20" class="input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">邮箱：</label>
			<div class="controls">
				<form:input path="backUpc" htmlEscape="false" maxlength="20" class="input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">地址：</label>
			<div class="controls">
				<form:textarea path="addr" htmlEscape="false" rows="1" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">排序：</label>
			<div class="controls">
				<form:input path="sort" htmlEscape="false" class="input-xlarge required digits"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group" >
			<label class="control-label">店信息：</label>
			<div class="controls">
				<form:textarea path="storeInfo" htmlEscape="false" rows="2" maxlength="255" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group" >
			<label class="control-label">安全生产：<input id="securProductType" type="checkbox" onclick="securProductTypeClick(this)"/></label>
			<label class="control-label"><input id="securProduct"  type="checkbox"  />安全管理巡查表</label>
		</div>
		<div class="control-group" >
			<label class="control-label">食品：<input id="shipinsType" type="checkbox" onclick="shipinType(this)"/></label>
			<label class="control-label"><input id="shipin"  type="checkbox"  />食品管理巡查表</label>
		</div>
		<div class="control-group" >
			<label class="control-label">消防：<input id="chuzuwu" type="checkbox" onclick="chuzuwuClick(this)"/></label>
			<label class="control-label"><input id="xfcz"  type="checkbox"  />出租屋基础排查表</label>
			<label class="control-label"><input id="xfdm" type="checkbox"  />店面基础排查表</label>
		</div>
		<div class="control-group" >
			<label class="control-label">燃气：<input id="ranqi" type="checkbox" onclick="ranqiClick(this)"/></label>
			<label class="control-label" style="width:225px"><input id="rqgd" type="checkbox" />管道燃气用气场所安全检查表</label>
			<label class="control-label" style="width:225px"><input id="rqgh" type="checkbox" />液化石油用气场所安全检查表</label>
		</div>
		<div class="control-group hide xfcz" >
			<label class="control-label">出租屋层数：</label>
			<div class="controls">
				<input name="floorNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfcz xfdm" >
			<label class="control-label">面积：</label>
			<div class="controls">
				<input name="area" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfcz" >
			<label class="control-label">居住人数：</label>
			<div class="controls">
				<input name="personNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfcz xfdm" >
			<label class="control-label">车牌号：</label>
			<div class="controls">
				<input name="plateNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfdm" >
			<label class="control-label">所在主体建筑名称：</label>
			<div class="controls">
				<input name="architectureName" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfdm" >
			<label class="control-label">单位（场所）名称：</label>
			<div class="controls">
				<input name="placeName" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfdm rqgd rqgh" >
			<label class="control-label">工商营业执照：</label>
			<div class="controls">
				<input name="businessLicense" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide xfdm" >
			<label class="control-label">消防审核情况：</label>
			<div class="controls">
				<select name="fireAudit" htmlEscape="false" class="input-xlarge ">
				<c:forEach items="${fireAuditList}" var="list">
					<option value="${list.value}">${list.label}</option>
				</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide xfdm" >
			<label class="control-label">场所类别：</label>
			<div class="controls">
				<select name="placeCategory" htmlEscape="false" maxlength="20" class="input-xlarge">
				    <c:forEach items="${placeCategoryList}" var="list">
						<option value="${list.value}">${list.label}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide rqgd rqgh" >
			<label class="control-label">用气性质：</label>
			<div class="controls">
				<select name="gasProperty" htmlEscape="false" maxlength="20" class="input-xlarge ">
				<c:forEach items="${gasPropertyList}" var="list">
					<option value="${list.value}">${list.label}</option>
				</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide rqgd" >
			<label class="control-label">身份证：</label>
			<div class="controls">
				<input name="idCard" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgd" >
			<label class="control-label">管道燃气表单编号：</label>
			<div class="controls">
				<input name="gdtableNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">液化石油表单编号：</label>
			<div class="controls">
				<input name="ghtableNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">餐饮店名称：</label>
			<div class="controls">
				<input name="storeName" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">户外招牌：</label>
			<div class="controls">
				<input name="outdoorSign" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">供气单位名称：</label>
			<div class="controls">
				<select name="gasCompany" htmlEscape="false" maxlength="20" class="input-xlarge ">
					<c:forEach items="${gasCompanyList}" var="list">
						<option value="${list.value}">${list.label}</option>
					</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">供气合同编号：</label>
			<div class="controls">
				<input name="gasNumber" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">供气类型（瓶装）：</label>
			<div class="controls">
				<select name="gasType" htmlEscape="false" maxlength="20" class="input-xlarge ">
				<c:forEach items="${gasTypeList}" var="list">
					<option value="${list.value}">${list.label}</option>
				</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">数量：</label>
			<div class="controls">
				<input name="gasBottleNumber" htmlEscape="false" maxlength="10" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">购买凭证：</label>
			<div class="controls">
				<select name="purchaseVoucher" htmlEscape="false" maxlength="20" class="input-xlarge ">
				<c:forEach items="${purchaseVoucherList}" var="list">
					<option value="${list.value}">${list.label}</option>
				</c:forEach>
				</select>
			</div>
		</div>
		<div class="control-group hide rqgh" >
			<label class="control-label">条形码号：</label>
			<div class="controls">
				<input name="backUpa" htmlEscape="false" maxlength="20" class="input-xlarge "/>
			</div>
		</div>
		<input id="xfczid"  value="0" name="xfczid" class="hide" />
		<input id="xfdmid"  value="0" name="xfdmid" class="hide"/>
		<input id="rqgdid"  value="0" name="rqgdid" class="hide"/>
		<input id="rqghid"  value="0" name="rqghid" class="hide"/>
		<input id="shipinid"  value="0" name="shipinid" class="hide"/>
		<input id="securProductid"  value="0" name="securProductid" class="hide"/>
		<div class="form-actions">
			<shiro:hasPermission name="ajz:ajzBaseinfo:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<script type="text/javascript">
		$().ready(function(){
			//给液化石油加change事件
			$("#rqgh").on("change",function(){
				if($("#rqgh").attr("checked")){
					$(".rqgh").show();
					$("#rqghid").val(1);
				}else{
					$(".rqgh").hide();
					$("#rqghid").val(0);
				}
				if($("#rqgd").attr("checked")&&$("#rqgh").attr("checked")){
					$("#ranqi").attr("checked","true");
				}else{
					$("#ranqi").removeAttr("checked");
				}
			});
			//给燃气管道加change事件
			$("#rqgd").on("change",function(){
				if($("#rqgd").attr("checked")){
					$(".rqgd").show();
					$("#rqgdid").val(1);
				}else{
					$(".rqgd").hide();
					$("#rqgdid").val(0);
				}
				if($("#rqgd").attr("checked")&&$("#rqgh").attr("checked")){
					$("#ranqi").attr("checked","true");
				}else{
					$("#ranqi").removeAttr("checked");
				}
			});
			
			//给出租屋加change事件
			$("#xfcz").on("change",function(){
				if($("#xfcz").attr("checked")){
					$(".xfcz").show();
					$("#xfczid").val(1);
				}else{
					$(".xfcz").hide();
					$("#xfczid").val(0);
				}
				if($("#xfcz").attr("checked")&&$("#xfdm").attr("checked")){
					$("#chuzuwu").attr("checked","true");
				}else{
					$("#chuzuwu").removeAttr("checked");
				}
			});
			
			//给店面加change事件
			$("#xfdm").on("change",function(){
				if($("#xfdm").attr("checked")){
					$(".xfdm").show();
					$("#xfdmid").val(1);
				}else{
					$(".xfdm").hide();
					$("#xfdmid").val(0);
				}
				if($("#xfcz").attr("checked")&&$("#xfdm").attr("checked")){
					$("#chuzuwu").attr("checked","true");
				}else{
					$("#chuzuwu").removeAttr("checked");
				}
			});
			
			//给食品加change事件
			$("#shipin").on("change",function(){
				if($("#shipin").attr("checked")){
					$("#shipinid").val(1);
				}else{
					$("#shipinid").val(0);
				}
				if($("#shipin").attr("checked")){
					$("#shipinsType").attr("checked","true");
				}else{
					$("#shipinsType").removeAttr("checked");
				}
			});
			
			//给安全生产加change事件
			$("#securProduct").on("change",function(){
				if($("#securProduct").attr("checked")){
					$("#securProductid").val(1);
				}else{
					$("#securProductid").val(0);
				}
				if($("#securProduct").attr("checked")){
					$("#securProductType").attr("checked","true");
				}else{
					$("#securProductType").removeAttr("checked");
				}
			});
		});
		var ajzXfCzw=${ajzXfCzw};
		var ajxXfDm=${ajxXfDm};
		var ajzRiGd=${ajzRiGd};
		var ajzRiGh=${ajzRiGh};
		var tableName=${jsonajzBaseinfo}['tableName'];
		if(tableName.indexOf("ajz_sp")>=0){
			shipin();
			$('#shipin').trigger("change");
		}
		if(tableName.indexOf("ajz_aqsc")>=0){
			securProduct();
			$('#securProduct').trigger("change");
		}
		if(ajzXfCzw != null){
			xfcz();
			$('#xfcz').trigger("change");
			$("[name='floorNumber']").val(ajzXfCzw["floorNumber"]);
			$("[name='area']").val(ajzXfCzw["area"]);
			$("[name='personNumber']").val(ajzXfCzw["personNumber"]);
			$("[name='plateNumber']").val(ajzXfCzw["plateNumber"]);
		}
		if(ajxXfDm!=null){
			xfdm();
			$('#xfdm').trigger("change");
			$("[name='area']").val(ajxXfDm["area"]);
			$("[name='plateNumber']").val(ajxXfDm["plateNumber"]);
			$("[name='architectureName']").val(ajxXfDm["architectureName"]);
			$("[name='placeName']").val(ajxXfDm["placeName"]);
			$("[name='businessLicense']").val(ajxXfDm["businessLicense"]);
			$("[name='fireAudit']").val(ajxXfDm["fireAudit"]);
			$("[name='placeCategory']").val(ajxXfDm["placeCategory"]);
		}
		if(ajzRiGd != null){
			rqgd();
			$('#rqgd').trigger("change");
			$("[name=gasProperty] option[value="+ajzRiGd["gasProperty"]+"]").attr("selected",true);
			$("[name='businessLicense']").val(ajzRiGd["businessLicense"]);
			$("[name='idCard']").val(ajzRiGd["idCard"]);
			$("[name='gdtableNumber']").val(ajzRiGd["tableNumber"]);
		}
		if(ajzRiGh != null){
			rqgh();
			$('#rqgh').trigger("change");
			$("[name='businessLicense']").val(ajzRiGh["businessLicense"]);
			$("[name='gasProperty']").val(ajzRiGh["gasProperty"]);
			$("[name='ghtableNumber']").val(ajzRiGh["tableNumber"]);
			$("[name='storeName']").val(ajzRiGh["storeName"]);
			$("[name='outdoorSign']").val(ajzRiGh["outdoorSign"]);
			$("[name='gasCompany']").val(ajzRiGh["gasCompany"]);
			$("[name='gasNumber']").val(ajzRiGh["gasNumber"]);
			$("[name='gasType']").val(ajzRiGh["gasType"]);
			$("[name='gasBottleNumber']").val(ajzRiGh["gasBottleNumber"]);
			$("[name='purchaseVoucher']").val(ajzRiGh["purchaseVoucher"]);
			$("[name='backUpa']").val(ajzRiGh["backUpa"]);
		}
		
		//消防点击事件
		function chuzuwuClick(obj){
			if($(obj).attr("checked")){
				$("#xfcz").attr("checked","true");
				$("#xfdm").attr("checked","true");
			}else {
				$("#xfcz").removeAttr("checked");
				$("#xfdm").removeAttr("checked");
			}
			$('#xfcz').trigger("change");
			$('#xfdm').trigger("change");
		}
		
		//食品
		function shipinType(obj){
			if($(obj).attr("checked")){
				$("#shipin").attr("checked","true");
			}else{
				$("#shipin").removeAttr("checked");
			}
			$('#shipin').trigger("change");
		}
		
		//安全生产
		function securProductTypeClick(obj){
			if($(obj).attr("checked")){
				$("#securProduct").attr("checked","true");
			}else{
				$("#securProduct").removeAttr("checked");
			}
			$('#securProduct').trigger("change");
		}
		
		//燃气事件
		function ranqiClick(obj){
			if($(obj).attr("checked")){
				$("#rqgh").attr("checked","true");
				$("#rqgd").attr("checked","true");
			}else {
				$("#rqgh").removeAttr("checked");
				$("#rqgd").removeAttr("checked");
			}
			$('#rqgd').trigger("change");
			$('#rqgh').trigger("change");
		}
		
		function securProduct(){
			$("#securProductid").val(1);
			$("#securProduct").attr("checked",true);
		}
		
		function shipin(){
			$("#shipinid").val(1);
			$("#shipin").attr("checked",true);
		}
		
		function xfcz(){
			$(".xfcz").show();
			$("#xfczid").val(1);
			$("#xfcz").attr("checked",true);
		}
		
		function xfdm(){
			$(".xfdm").show();
			$("#xfdmid").val(1);
			$("#xfdm").attr("checked",true);
		}
		
		function rqgh(){
			$(".rqgh").show();
			$("#rqghid").val(1);
			$("#rqgh").attr("checked",true);
		}
		
		function rqgd(){
			$(".rqgd").show();
			$("#rqgdid").val(1);
			$("#rqgd").attr("checked",true);
		}
		
	</script>
</body>
</html>